package com.qf.controller;

import com.qf.vo.EmailVo;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class RegisterController {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @GetMapping("/regist")
    public String regist(String username,String password,String email){

        //1. 注册逻辑 。。。。


        // 发送邮件
        // 封装发邮件的对象，写入mq即可
        EmailVo emailVo = new EmailVo();
        emailVo.setTitle("欢迎使用mq系统");
        emailVo.setTo(email);
        emailVo.setContent("欢迎使用mq系统,"+username);

        rabbitTemplate.convertAndSend("","email-queue",emailVo);

        return "ok";
    }

}
